package com.marvels.approve.loan.service.impl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.dragon.loan.dto.UserAgentDTO;
import com.dragon.loan.service.AcUserAgentMappingService;
import com.fintech.common.util.ApiResponse;
import com.fintech.common.utils.ConvertUtil;
import com.fintech.third.model.predictmessage.EdcMessagePredictInfo;
import com.fintech.third.model.predictmessage.EdcRiskModel;
import com.fintech.third.service.credit.CreditReportService;
import com.fintech.third.service.predictmessage.PredictMessageService;
import com.fintech.third.service.shzx.ShangHaiLogInService;
import com.fintech.third.service.youdun.YdService;
import com.marvels.approve.credit.service.ApproveThirdCreditReportService;
import com.marvels.approve.loan.dao.McamAutoDecisionMapper;
import com.marvels.approve.loan.dao.McamAutoDecisionRecordMapper;
import com.marvels.approve.loan.dto.McamAutoDecisionRecord;
import com.marvels.approve.loan.dto.McamAutoDecisionWithBLOBs;
import com.marvels.approve.loan.dto.McamLoanApplyInfoDTO;
import com.marvels.approve.loan.service.DecisionService;
import com.marvels.common.data.DataRow;
import com.marvels.common.exception.MarvelsBusinessException;
import com.marvels.common.utils.IdCarUtils;
import com.marvels.common.utils.MarvelsLogUtil;
import com.marvels.system.common.dao.McsmRevealConfigureAppDao;
import com.marvels.system.common.dto.McsmRevealConfigureAppDTO;

import cn.hutool.core.util.StrUtil;

/**
 * 
* @ClassName: DecisionService 
* @Description:自动审核服务类 
* @author 李瑶
* @date 2018年10月8日 下午1:40:19 
*
 */
@Service
public class DecisionServiceImpl implements DecisionService {
	
	@Autowired
	private McamAutoDecisionMapper mcamAutoDecisionMapper;
	
	@Autowired
	private McamAutoDecisionRecordMapper mcamAutoDecisionRecordMapper;
	
    @Autowired
    private CreditReportService creditReportService;
    
    @Autowired
	private ShangHaiLogInService shangHaiLogInService;
    
    @Autowired
    private YdService ydservice;
    
    @Autowired
    private ApproveThirdCreditReportService thirdCreditReportService;
	
	@Autowired
	private PredictMessageService predictMessageService;
	
	@Autowired
	private McsmRevealConfigureAppDao mcsmRevealConfigureAppDao;
		
	@Autowired
	private AcUserAgentMappingService acUserAgentMappingService;
	/**
	 * 
	* @Title: getDecisionData 
	* @Description: 查询组装自动审核需要的数据 
	* @param mcamLoanApplyInfo
	* @return       
	* @author 李瑶
	* @date 2018年10月13日 上午11:16:53
	 */
	private Map<String, Object> getDecisionData(McamLoanApplyInfoDTO mcamLoanApplyInfo){
		String orgLoanId = mcamLoanApplyInfo.getLoanId();
		String loanId =  thirdCreditReportService.getThirdLoanId(mcamLoanApplyInfo.getLoanId());
		String userId = mcamLoanApplyInfo.getCustCode();
		Map<String, Object> decisionData = creditReportService.getAutoDecisionData(loanId, orgLoanId, userId, mcamLoanApplyInfo.getMobileNo());
		decisionData.put("sex", mcamLoanApplyInfo.getCustSex());
		decisionData.put("age", mcamLoanApplyInfo.getCustAge());
		decisionData.put("cardNo", mcamLoanApplyInfo.getCustCardNo());
		decisionData.put("mobile", mcamLoanApplyInfo.getMobileNo());
		return decisionData;
	}
	
	

	
	/**
	 * 
	* @Title: doDecision 
	* @Description:自动审核  
	* @param originalLoan
	* @return       
	* @author 李瑶
	* @date 2018年10月8日 下午1:41:07
	 */
	@Override
	public boolean doDecision(McamLoanApplyInfoDTO mcamLoanApplyInfo) throws MarvelsBusinessException {
		boolean result = true;
		
		// 获取第三方数据并获取决策数据
		Map<String, Object> autoDecisionData = getThirdData(mcamLoanApplyInfo);
		List<McamAutoDecisionRecord> decisionRecordList = new ArrayList<McamAutoDecisionRecord>();
		//身份证
		String idno = mcamLoanApplyInfo.getCustCardNo();
		
		//Map<String, Object> autoDecisionData = getDecisionData(mcamLoanApplyInfo);
		MarvelsLogUtil.getInstance().info(mcamLoanApplyInfo.getLoanId() + ",决策数据：" + JSONObject.toJSONString(autoDecisionData));
		DataRow ruleMap  = this.geRuleMap();
		int rejectNum = 0;
		//魔蝎蚂蚁芝麻分判定
		McsmRevealConfigureAppDTO ruleAntScoreMinDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleAntScoreMin");
		if(ruleAntScoreMinDto != null){
			int ruleAntScoreMin = Integer.parseInt(ruleAntScoreMinDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object antScoreObj = autoDecisionData.get("antScore");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("芝麻信用分");
			mcamAutoDecisionRecord.setRuleDescription("最小值为：" + ruleAntScoreMin);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(antScoreObj != null){
				int antScoreData = (int)antScoreObj;
				mcamAutoDecisionRecord.setUserDetail("用户芝麻信用分为："+antScoreData+"分");
				String status = antScoreData < ruleAntScoreMin ? "1" : "0";
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleAntScoreMinDto.getConfigTemp1() == 1){
						result = false;
					}
				}
				mcamAutoDecisionRecord.setStatus(status);
				
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户芝麻信用分为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		
		//任务画像风险指数
		McsmRevealConfigureAppDTO rulePortraitMaxDto = (McsmRevealConfigureAppDTO) ruleMap.get("rulePortraitMax");
		if(rulePortraitMaxDto != null){
			int rulePortraitMax = Integer.parseInt(rulePortraitMaxDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object portraitObj = autoDecisionData.get("portrait");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("人物画像风险指数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + rulePortraitMax);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(portraitObj!=null){
				double portrait = (double)portraitObj;
				mcamAutoDecisionRecord.setUserDetail("用户人物画像指数为："+portrait);
				String status = portrait > rulePortraitMax ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum++;
					// 是否自动拒绝
					if(rulePortraitMaxDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户人物画像指数为(未知)");

			}
			decisionRecordList.add(mcamAutoDecisionRecord);
			
		}

		//年龄
		McsmRevealConfigureAppDTO ruleAgeMaxDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleAgeMax");
		McsmRevealConfigureAppDTO ruleAgeMinDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleAgeMin");
		if(ruleAgeMaxDto != null || ruleAgeMinDto != null){
			String status = "0";
			//年龄
			int age = mcamLoanApplyInfo.getCustAge();
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("年龄");
			mcamAutoDecisionRecord.setUserDetail("用户年龄为："+age);
			if(ruleAgeMaxDto != null && ruleAgeMinDto != null){
				int ruleAgeMax = Integer.parseInt(ruleAgeMaxDto.getConfigValue());
				int ruleAgeMin = Integer.parseInt(ruleAgeMinDto.getConfigValue());
				status = (age < ruleAgeMin || age > ruleAgeMax) ? "1" : "0";
				mcamAutoDecisionRecord.setRuleDescription("年龄限制为：" + ruleAgeMin + "周岁到" + ruleAgeMax + "周岁之间");
				// 是否自动拒绝
				if("1".equals(status) && ruleAgeMaxDto.getConfigTemp1() == 1 && ruleAgeMinDto.getConfigTemp1() == 1){
					result = false;
				}
			}else if(ruleAgeMaxDto != null){
				int ruleAgeMax = Integer.parseInt(ruleAgeMaxDto.getConfigValue());
				status = age > ruleAgeMax ? "1" : "0";
				mcamAutoDecisionRecord.setRuleDescription("年龄限制为小于" + ruleAgeMax + "周岁");
				// 是否自动拒绝
				if("1".equals(status) && ruleAgeMaxDto.getConfigTemp1() == 1){
					result = false;
				}
			}else if(ruleAgeMinDto != null){
				int ruleAgeMin = Integer.parseInt(ruleAgeMinDto.getConfigValue());
				status = age < ruleAgeMin ? "1" : "0";
				mcamAutoDecisionRecord.setRuleDescription("年龄限制为大于" + ruleAgeMin + "周岁");
				// 是否自动拒绝
				if("1".equals(status) && ruleAgeMinDto.getConfigTemp1() == 1){
					result = false;
				}
			}
			mcamAutoDecisionRecord.setStatus(status);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			decisionRecordList.add(mcamAutoDecisionRecord);
			if("1".equals(status)){
				rejectNum++;
			}
		}

		
		
		//联系人中黑名单占比
		McsmRevealConfigureAppDTO ruleContactForbidenPercentDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleContactForbidenPercent");
		if(ruleContactForbidenPercentDto != null){
			double ruleContactForbidenPercent = Double.parseDouble(ruleContactForbidenPercentDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object contactForbidenPercentObj = autoDecisionData.get("contactForbidenPercent");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("运营商报告的直接联系人中引起间接黑明单占比");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleContactForbidenPercent);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(contactForbidenPercentObj!=null){
				double contactForbidenPercent = (double)contactForbidenPercentObj;
				mcamAutoDecisionRecord.setUserDetail("用户的直接联系人中引起间接黑明单占比为："+contactForbidenPercent);
				String status = contactForbidenPercent > ruleContactForbidenPercent ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum++;
					// 是否自动拒绝
					if(ruleContactForbidenPercentDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户的直接联系人中引起间接黑明单占比为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
			
		}

		//近一月手机关机次数
		McsmRevealConfigureAppDTO ruleClosePhoneDaysMaxDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleClosePhoneDaysMax");
		if(ruleClosePhoneDaysMaxDto != null){
			int ruleClosePhoneDaysMax = Integer.parseInt(ruleClosePhoneDaysMaxDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object closePhoneDaysObj = autoDecisionData.get("closePhoneDays");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("近六个月手机关机天数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleClosePhoneDaysMax);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			
			if(closePhoneDaysObj!=null){
				int closePhoneDays = (int)closePhoneDaysObj;
				mcamAutoDecisionRecord.setUserDetail("用户近六个月手机关机天数为："+closePhoneDays);
				String status = closePhoneDays > ruleClosePhoneDaysMax ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum++;
					// 是否自动拒绝
					if(ruleClosePhoneDaysMaxDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户近六个月手机关机天数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}

		//身份证所在省份禁止进件
		McsmRevealConfigureAppDTO ruleIdcardLimitProvinceDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleIdcardLimitProvince");
		if(ruleIdcardLimitProvinceDto != null){
			String ruleIdcardLimitProvince = ruleIdcardLimitProvinceDto.getConfigValue();
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//身份证所在省份
			String idProvince = IdCarUtils.getProvinceByIdCard(idno);		
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("身份证地区限制");
			mcamAutoDecisionRecord.setRuleDescription("省份限制有：" + ruleIdcardLimitProvince);
			mcamAutoDecisionRecord.setUserDetail("用户身份证号地区为：" + idProvince);
			String status = ruleIdcardLimitProvince.indexOf(idProvince) != -1 ? "1" : "0";
			mcamAutoDecisionRecord.setStatus(status);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			decisionRecordList.add(mcamAutoDecisionRecord);
			if("1".equals(status)){
				rejectNum++;
				// 是否自动拒绝
				if(ruleIdcardLimitProvinceDto.getConfigTemp1() == 1){
					result = false;
				}
			}
		}
		
		//近三月催收电话通话次数
		McsmRevealConfigureAppDTO ruleCollectionTimesDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleCollectionTimes");
		if(ruleCollectionTimesDto != null){
			int ruleCollectionTimes = Integer.parseInt(ruleCollectionTimesDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object collectionTimesObj = autoDecisionData.get("collectionTimes");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("近三个月催收通话次数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleCollectionTimes);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			
			if(collectionTimesObj!=null){
				int collectionTimes = (int)collectionTimesObj;
				mcamAutoDecisionRecord.setUserDetail("用户近三个月催收通话次数为："+collectionTimes);
				String status = collectionTimes > ruleCollectionTimes ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum++;
					// 是否自动拒绝
					if(ruleCollectionTimesDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户近三个月催收通话次数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}

		//逾期平台数
		McsmRevealConfigureAppDTO ruleOverduePlatNumDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleOverduePlatNum");
		if(ruleOverduePlatNumDto != null){
			try {
				int ruleOverduePlatNum = Integer.parseInt(ruleOverduePlatNumDto.getConfigValue());
				McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
				Object overduePlatNumObj = autoDecisionData.get("overduePlatCount");
				mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
				mcamAutoDecisionRecord.setRuleName("当前逾期平台数（平台内部数据共享）");
				mcamAutoDecisionRecord.setCreatedBy("sys");
				mcamAutoDecisionRecord.setUpdatedBy("sys");
				mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleOverduePlatNum);
				if(overduePlatNumObj!=null){
					int overduePlatNum = Integer.parseInt(overduePlatNumObj.toString());
					mcamAutoDecisionRecord.setUserDetail("用户当前逾期平台数为："+overduePlatNum);
					String status = overduePlatNum > ruleOverduePlatNum ? "1" : "0";
					mcamAutoDecisionRecord.setStatus(status);
					if("1".equals(status)){
						rejectNum++;
						// 是否自动拒绝
						if(ruleOverduePlatNumDto.getConfigTemp1() == 1){
							result = false;
						}
					}
				}else{
					mcamAutoDecisionRecord.setUserDetail("用户当前逾期平台数为(未知)");
				}
				decisionRecordList.add(mcamAutoDecisionRecord);
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>mobileNo:"+mcamLoanApplyInfo.getMobileNo()+",平台共享数据决策异常",e);
			}
		}

		//手机入网时长
		McsmRevealConfigureAppDTO rulePhoneIntNetTimeDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("rulePhoneIntNetTime");
		if(rulePhoneIntNetTimeDto != null){
			int rulePhoneIntNetTime = Integer.parseInt(rulePhoneIntNetTimeDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object inNetMonthObj = autoDecisionData.get("in_time");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("手机入网时长");
			mcamAutoDecisionRecord.setRuleDescription("入网时长最小值为："+rulePhoneIntNetTime+"月");
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(inNetMonthObj!=null){
				int inNetMonth = (int)autoDecisionData.get("in_time");
				mcamAutoDecisionRecord.setUserDetail("用户入网时长为："+inNetMonth+"月");
				String status = inNetMonth < rulePhoneIntNetTime ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum++;
					// 是否自动拒绝
					if(rulePhoneIntNetTimeDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户入网时长为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		
		
		//运营商姓名和身份证姓名是否一致
		McsmRevealConfigureAppDTO ruleYysSameNameDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleYysSameName");
		if(ruleYysSameNameDto != null && "1".equals(ruleYysSameNameDto.getConfigValue())){
			Object mxCustNameObj = autoDecisionData.get("mxCustName");
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("身份证姓名与运营商里的名字须一致");
			String userName = mcamLoanApplyInfo.getCustName();	
			if(mxCustNameObj != null){
				String ruleUserName = (String)autoDecisionData.get("mxCustName");
				//身份证所在省份
				mcamAutoDecisionRecord.setRuleDescription("运营商中姓名：" + ruleUserName);
				mcamAutoDecisionRecord.setUserDetail("用户身份证姓名：" + userName);
				String status = !ruleUserName.equals(userName) ? "1" : "0";
				if (status.equals("1")) {// 运营商中姓名与用户身份证姓名不一致则判断掩码
					StringBuffer sb = new StringBuffer();
					Pattern p = Pattern.compile("\\*");
					Matcher m = p.matcher(ruleUserName);
					while (m.find()) {
						String v = "";
						// 注意，在替换字符串中使用反斜线 (\) 和美元符号 ($) 可能导致与作为字面值替换字符串时所产生的结果不同。
						// 美元符号可视为到如上所述已捕获子序列的引用，反斜线可用于转义替换字符串中的字面值字符。
						v = v.replace("\\", "\\\\").replace("$", "\\$");
						// 替换掉查找到的字符串
						m.appendReplacement(sb, v);
					}
					// 别忘了加上最后一点
					m.appendTail(sb);
					if(userName.contains(sb.toString())){
						status="0";
					}
				}
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum++;
					// 是否自动拒绝
					if(ruleYysSameNameDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setRuleDescription("运营商中姓名：(未知)");
				mcamAutoDecisionRecord.setUserDetail("用户身份证姓名：" + userName);
			}
			decisionRecordList.add(mcamAutoDecisionRecord);

		}
		//通讯录联系人最小数
		McsmRevealConfigureAppDTO ruleContactNumMinDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleContactNumMin");
		if(ruleContactNumMinDto != null){
			int ruleContactNumMin = Integer.parseInt(ruleContactNumMinDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object contactNumObj = autoDecisionData.get("contactNum");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("通讯录条数");
			mcamAutoDecisionRecord.setRuleDescription("最小值为：" + ruleContactNumMin);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(contactNumObj!=null){
				int contactNum = (int)autoDecisionData.get("contactNum");
				mcamAutoDecisionRecord.setUserDetail("用户通讯录条数为：" + contactNum);
				String status = contactNum < ruleContactNumMin ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum++;
					// 是否自动拒绝
					if(ruleContactNumMinDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户通讯录条数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		
		//短信模型评分最小值
		McsmRevealConfigureAppDTO ruleMsgScoreMinDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleMsgScoreMin");
		if(ruleMsgScoreMinDto != null){
			int ruleMsgScoreMin = Integer.parseInt(ruleMsgScoreMinDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object msgScoreObj = autoDecisionData.get("msgScore");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("短信模型分");
			mcamAutoDecisionRecord.setRuleDescription("最小值为：" + ruleMsgScoreMin);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(msgScoreObj != null){
				int msgScore = (int)autoDecisionData.get("msgScore");
				mcamAutoDecisionRecord.setUserDetail("用户短信模型分为：" + msgScore);
				String status = msgScore < ruleMsgScoreMin ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleMsgScoreMinDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户短信模型分为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		
		//近1月申请借款平台数
		McsmRevealConfigureAppDTO ruleLoanPlatformCount1mDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleLoanPlatformCount1m");
		if(ruleLoanPlatformCount1mDto != null){
			int ruleLoanPlatformCount1m = Integer.parseInt(ruleLoanPlatformCount1mDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object loanPlatformCount1mObj = autoDecisionData.get("loanPlatformCount1m");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("近1月申请借款平台数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleLoanPlatformCount1m);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(loanPlatformCount1mObj != null){
				int loanPlatformCount1m = (int)autoDecisionData.get("loanPlatformCount1m");
				mcamAutoDecisionRecord.setUserDetail("用户近1月申请借款平台数为：" + loanPlatformCount1m);
				String status = loanPlatformCount1m > ruleLoanPlatformCount1m ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleLoanPlatformCount1mDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户近1月申请借款平台数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		//近3月申请借款平台数
		McsmRevealConfigureAppDTO ruleLoanPlatformCount3mDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleLoanPlatformCount3m");
		if(ruleLoanPlatformCount3mDto != null){
			int ruleLoanPlatformCount3m = Integer.parseInt(ruleLoanPlatformCount3mDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object loanPlatformCount3mObj = autoDecisionData.get("loanPlatformCount3m");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("近3月申请借款平台数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleLoanPlatformCount3m);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(loanPlatformCount3mObj != null){
				int loanPlatformCount3m = (int)autoDecisionData.get("loanPlatformCount3m");
				mcamAutoDecisionRecord.setUserDetail("用户近3月申请借款平台数为：" + loanPlatformCount3m);
				String status = loanPlatformCount3m > ruleLoanPlatformCount3m ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleLoanPlatformCount3mDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户近3月申请借款平台数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		//近6月申请借款平台数
		McsmRevealConfigureAppDTO ruleLoanPlatformCount6mDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleLoanPlatformCount6m");
		if(ruleLoanPlatformCount6mDto != null){
			int ruleLoanPlatformCount6m = Integer.parseInt(ruleLoanPlatformCount6mDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object loanPlatformCount6mObj = autoDecisionData.get("loanPlatformCount6m");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("近6月申请借款平台数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleLoanPlatformCount6m);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(loanPlatformCount6mObj != null){
				int loanPlatformCount6m = (int)autoDecisionData.get("loanPlatformCount6m");
				mcamAutoDecisionRecord.setUserDetail("用户近6月申请借款平台数为：" + loanPlatformCount6m);
				String status = loanPlatformCount6m > ruleLoanPlatformCount6m ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleLoanPlatformCount6mDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户近6月申请借款平台数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		//申请借款平台数
		McsmRevealConfigureAppDTO ruleLoanPlatformCountDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleLoanPlatformCount");
		if(ruleLoanPlatformCountDto != null){
			int ruleLoanPlatformCount = Integer.parseInt(ruleLoanPlatformCountDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object loanPlatformCountObj = autoDecisionData.get("loanPlatformCount");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("申请借款平台数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleLoanPlatformCount);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(loanPlatformCountObj != null){
				int loanPlatformCount = (int)autoDecisionData.get("loanPlatformCount");
				mcamAutoDecisionRecord.setUserDetail("用户申请借款平台数为：" + loanPlatformCount);
				String status = loanPlatformCount > ruleLoanPlatformCount ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleLoanPlatformCountDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户申请借款平台数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		
		//黑中介分数
		McsmRevealConfigureAppDTO ruleAgencyScoreDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleAgencyScore");
		if(ruleAgencyScoreDto != null){
			int ruleAgencyScore = Integer.parseInt(ruleAgencyScoreDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object agencyScoreObj = autoDecisionData.get("agencyScore");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("黑中介分数");
			mcamAutoDecisionRecord.setRuleDescription("最小值为：" + ruleAgencyScore);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(agencyScoreObj != null){
				int agencyScore = (int)autoDecisionData.get("agencyScore");
				mcamAutoDecisionRecord.setUserDetail("用户黑中介分数为：" + agencyScore);
				String status = agencyScore < ruleAgencyScore ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleAgencyScoreDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户黑中介分数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		
		//查询过该用户的相关企业数量（姓名+身份证+电话号码）
		McsmRevealConfigureAppDTO ruleSearchedOrgCntDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleSearchedOrgCnt");
		if(ruleSearchedOrgCntDto != null){
			int ruleSearchedOrgCnt = Integer.parseInt(ruleSearchedOrgCntDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object searchedOrgCntObj = autoDecisionData.get("searchedOrgCnt");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("查询过该用户的相关企业数量");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleSearchedOrgCnt);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(searchedOrgCntObj != null){
				int searchedOrgCnt = (int)autoDecisionData.get("searchedOrgCnt");
				mcamAutoDecisionRecord.setUserDetail("用户实际查询过该用户的相关企业数量为：" + searchedOrgCnt);
				String status = searchedOrgCnt > ruleSearchedOrgCnt ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleSearchedOrgCntDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户实际查询过该用户的相关企业数量为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		
		//电话号码注册过的相关企业数量
		McsmRevealConfigureAppDTO ruleRegisterOrgCntDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleRegisterOrgCnt");
		if(ruleRegisterOrgCntDto != null){
			int ruleRegisterOrgCnt = Integer.parseInt(ruleRegisterOrgCntDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object registerOrgCntObj = autoDecisionData.get("registerOrgCnt");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("电话号码注册过的相关企业数量");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleRegisterOrgCnt);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(registerOrgCntObj != null){
				int registerOrgCnt = (int)autoDecisionData.get("registerOrgCnt");
				mcamAutoDecisionRecord.setUserDetail("用户实际电话号码注册过的相关企业数量为：" + registerOrgCnt);
				String status = registerOrgCnt > ruleRegisterOrgCnt ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleRegisterOrgCntDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户实际电话号码注册过的相关企业数量为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 上海资信当前逾期贷款合同总额
		McsmRevealConfigureAppDTO ruleLoanOverdueTotalDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleLoanOverdueTotal");
		if(ruleLoanOverdueTotalDto != null){
			int ruleLoanOverdueTotal = Integer.parseInt(ruleLoanOverdueTotalDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object loanOverdueTotalObj = autoDecisionData.get("loanOverdueTotal");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("上海资信当前逾期贷款合同总额");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleLoanOverdueTotal);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(loanOverdueTotalObj != null){
				int loanOverdueTotal = (int)autoDecisionData.get("loanOverdueTotal");
				mcamAutoDecisionRecord.setUserDetail("用户上海资信当前逾期贷款合同总额为：" + loanOverdueTotal);
				String status = loanOverdueTotal >= ruleLoanOverdueTotal ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleLoanOverdueTotalDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户上海资信当前逾期贷款合同总额为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 上海资信近24个月逾期月数
		McsmRevealConfigureAppDTO ruleB24OverdueMonthsDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleB24OverdueMonths");
		if(ruleB24OverdueMonthsDto != null){
			int ruleB24OverdueMonths = Integer.parseInt(ruleB24OverdueMonthsDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object b24OverdueMonthsObj = autoDecisionData.get("b24OverdueMonths");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("上海资信近24个月逾期月数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleB24OverdueMonths);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(b24OverdueMonthsObj != null){
				int b24OverdueMonths = (int)autoDecisionData.get("b24OverdueMonths");
				mcamAutoDecisionRecord.setUserDetail("用户上海资信近24个月逾期月数为：" + b24OverdueMonths);
				String status = b24OverdueMonths >= ruleB24OverdueMonths ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleB24OverdueMonthsDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户上海资信近24个月逾期月数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 有盾用户使用手机号数
		McsmRevealConfigureAppDTO ruleMobileCountDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleMobileCount");
		if(ruleMobileCountDto != null){
			int ruleMobileCount = Integer.parseInt(ruleMobileCountDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object mobileCountObj = autoDecisionData.get("mobileCount");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("有盾用户使用手机号数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleMobileCount);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(mobileCountObj != null){
				int mobileCount = (int)autoDecisionData.get("mobileCount");
				mcamAutoDecisionRecord.setUserDetail("用户有盾使用手机号数为：" + mobileCount);
				String status = mobileCount >= ruleMobileCount ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleMobileCountDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户有盾使用手机号数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 有盾用户关联银行卡数
		McsmRevealConfigureAppDTO ruleBankcardCountDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleBankcardCount");
		if(ruleBankcardCountDto != null){
			int ruleBankcardCount = Integer.parseInt(ruleBankcardCountDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object bankcardCountObj = autoDecisionData.get("bankcardCount");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("有盾用户关联银行卡数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleBankcardCount);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(bankcardCountObj != null){
				int bankcardCount = (int)autoDecisionData.get("bankcardCount");
				mcamAutoDecisionRecord.setUserDetail("用户有盾关联银行卡数为：" + bankcardCount);
				String status = bankcardCount >= ruleBankcardCount ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleBankcardCountDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户有盾关联银行卡数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 有盾设备关联用户数
		McsmRevealConfigureAppDTO ruleLinkUserCountDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleLinkUserCount");
		if(ruleLinkUserCountDto != null){
			int ruleLinkUserCount = Integer.parseInt(ruleLinkUserCountDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object linkUserCountObj = autoDecisionData.get("linkUserCount");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("有盾设备关联用户数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleLinkUserCount);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(linkUserCountObj != null){
				int linkUserCount = (int)autoDecisionData.get("linkUserCount");
				mcamAutoDecisionRecord.setUserDetail("用户有盾设备关联用户数为：" + linkUserCount);
				String status = linkUserCount >= ruleLinkUserCount ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleLinkUserCountDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户有盾设备关联用户数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 有盾身份特质
		McsmRevealConfigureAppDTO ruleUserFeatureTypeDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleUserFeatureType");
		if(ruleUserFeatureTypeDto != null && ruleUserFeatureTypeDto.getConfigValue() != null){
			String ruleUserFeatureType = ruleUserFeatureTypeDto.getConfigValue();
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object userFeatureTypeObj = autoDecisionData.get("userFeatureType");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("有盾身份特质");
			mcamAutoDecisionRecord.setRuleDescription("限制类别有：" + ruleUserFeatureType);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(userFeatureTypeObj != null){
				String userFeatureType = (String)autoDecisionData.get("userFeatureType");
				List<String> userFeatureTypeList = Arrays.asList(userFeatureType.split(","));
				List<String> ruleUserFeatureTypeList = Arrays.asList(ruleUserFeatureType.split("\\|"));
				String featureTypeNames = "";
				String status = "0";
				for (int i = 0; i < userFeatureTypeList.size(); i++) {
					String featureTypeName = ConvertUtil.convertFeature(userFeatureTypeList.get(i));
					featureTypeNames +=  featureTypeName + (((i + 1) == userFeatureTypeList.size()) ? "" : "|");
					// 如果限制类别包含用户拥有的类别，则满足拒绝条件
					if(ruleUserFeatureTypeList.contains(featureTypeName)){
						status = "1";
					}
				}
				mcamAutoDecisionRecord.setUserDetail("用户有盾身份特质为：" + featureTypeNames);
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleUserFeatureTypeDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户有盾身份特质为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		
		// 有盾风险等级
		McsmRevealConfigureAppDTO ruleRiskEvaluatioDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleRiskEvaluation");
		if(ruleRiskEvaluatioDto != null && ruleRiskEvaluatioDto.getConfigValue() != null){
			String ruleRiskEvaluation = ruleRiskEvaluatioDto.getConfigValue();
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object riskEvaluationObj = autoDecisionData.get("riskEvaluation");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("有盾风险等级");
			mcamAutoDecisionRecord.setRuleDescription("限制类别为：" + ruleRiskEvaluation);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(riskEvaluationObj != null){
				String riskEvaluation = (String)autoDecisionData.get("riskEvaluation");
				List<String> ruleRiskEvaluationList = Arrays.asList(ruleRiskEvaluation.split("\\|"));
				mcamAutoDecisionRecord.setUserDetail("用户有盾风险等级为：" + riskEvaluation);
				// 如果限制类别包含用户拥有的类别，则满足拒绝条件
				String status = ruleRiskEvaluationList.contains(riskEvaluation) ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleRiskEvaluatioDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户有盾风险等级为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 共享平台黑名单数
		McsmRevealConfigureAppDTO ruleBlackPlatCountDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleBlackPlatCount");
		if(ruleBlackPlatCountDto != null){
			int ruleBlackPlatCount = Integer.parseInt(ruleBlackPlatCountDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object blackPlatCountObj = autoDecisionData.get("blackPlatCount");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("共享平台黑名单数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleBlackPlatCount);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(blackPlatCountObj != null){
				int blackPlatCount = (int)autoDecisionData.get("blackPlatCount");
				mcamAutoDecisionRecord.setUserDetail("用户共享平台黑名单数为：" + blackPlatCount);
				String status = blackPlatCount >= ruleBlackPlatCount ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleBlackPlatCountDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户共享平台黑名单数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		//近6个月前3通话次数总和最小值
		McsmRevealConfigureAppDTO ruleCall6mTop3NumberDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleCall6mTop3Number");
		if(ruleCall6mTop3NumberDto != null){
			int ruleCall6mTop3Number = Integer.parseInt(ruleCall6mTop3NumberDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object call6mTop3NumberObj = autoDecisionData.get("call6mTop3Number");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("近6个月前3通话次数总和");
			mcamAutoDecisionRecord.setRuleDescription("最小值为：" + ruleCall6mTop3Number);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(call6mTop3NumberObj != null){
				int call6mTop3Number = (int)autoDecisionData.get("call6mTop3Number");
				mcamAutoDecisionRecord.setUserDetail("用户近6个月前3通话次数总和为：" + call6mTop3Number);
				String status = call6mTop3Number < ruleCall6mTop3Number ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleCall6mTop3NumberDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户近6个月前3通话次数总和为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		
		//通话次数第10位最小值
		McsmRevealConfigureAppDTO ruleCallTenthNumberDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleCallTenthNumber");
		if(ruleCallTenthNumberDto != null){
			int ruleCallTenthNumber = Integer.parseInt(ruleCallTenthNumberDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object callTenthNumberObj = autoDecisionData.get("callTenthNumber");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("通话次数第10位");
			mcamAutoDecisionRecord.setRuleDescription("最小值为：" + ruleCallTenthNumber);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(callTenthNumberObj != null){
				int callTenthNumber = (int)autoDecisionData.get("callTenthNumber");
				mcamAutoDecisionRecord.setUserDetail("用户通话次数第10位为：" + callTenthNumber);
				String status = callTenthNumber < ruleCallTenthNumber ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleCallTenthNumberDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户通话次数第10位为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 近3个月前5通话总和最小值
		McsmRevealConfigureAppDTO ruleCall3mTop5NumberDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleCall3mTop5Number");
		if(ruleCall3mTop5NumberDto != null){
			int ruleCall3mTop5Number = Integer.parseInt(ruleCall3mTop5NumberDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object call3mTop5NumberObj = autoDecisionData.get("call3mTop5Number");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("近3个月前5通话总和");
			mcamAutoDecisionRecord.setRuleDescription("最小值为：" + ruleCall3mTop5Number);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(call3mTop5NumberObj != null){
				int call3mTop5Number = (int)autoDecisionData.get("call3mTop5Number");
				mcamAutoDecisionRecord.setUserDetail("用户近3个月前5通话总和为：" + call3mTop5Number);
				String status = call3mTop5Number < ruleCall3mTop5Number ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleCall3mTop5NumberDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户近3个月前5通话总和为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 通讯录没备注号码个数最大值
		McsmRevealConfigureAppDTO ruleLinkmansRemarkEmptyNumberDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleLinkmansRemarkEmptyNumber");
		if(ruleLinkmansRemarkEmptyNumberDto != null){
			int ruleLinkmansRemarkEmptyNumber = Integer.parseInt(ruleLinkmansRemarkEmptyNumberDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object linkmansRemarkEmptyNumberObj = autoDecisionData.get("linkmansRemarkEmptyNumber");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("通讯录没备注号码个数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleLinkmansRemarkEmptyNumber);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(linkmansRemarkEmptyNumberObj != null){
				int linkmansRemarkEmptyNumber = (int)autoDecisionData.get("linkmansRemarkEmptyNumber");
				mcamAutoDecisionRecord.setUserDetail("用户通讯录没备注号码个数为：" + linkmansRemarkEmptyNumber);
				String status = linkmansRemarkEmptyNumber >= ruleLinkmansRemarkEmptyNumber ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleLinkmansRemarkEmptyNumberDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户通讯录没备注号码个数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 总借款平台和还款平台差值最大值
		McsmRevealConfigureAppDTO ruleLoanRepaymentDifferenceDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleLoanRepaymentDifference");
		if(ruleLoanRepaymentDifferenceDto != null){
			int ruleLoanRepaymentDifference = Integer.parseInt(ruleLoanRepaymentDifferenceDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object loanRepaymentDifferenceObj = autoDecisionData.get("loanRepaymentDifference");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("总借款平台和还款平台差值");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleLoanRepaymentDifference);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(loanRepaymentDifferenceObj != null){
				double loanRepaymentDifference = (Double)autoDecisionData.get("loanRepaymentDifference");
				mcamAutoDecisionRecord.setUserDetail("用户总借款平台和还款平台差值为：" + loanRepaymentDifference);
				String status = loanRepaymentDifference >= ruleLoanRepaymentDifference ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleLoanRepaymentDifferenceDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户总借款平台和还款平台差值为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 借款平台和申请借款平台比例最小值
		McsmRevealConfigureAppDTO ruleLoanApplyProportionDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleLoanApplyProportion");
		if(ruleLoanApplyProportionDto != null){
			double ruleLoanApplyProportion = Double.parseDouble(ruleLoanApplyProportionDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object loanApplyProportionObj = autoDecisionData.get("loanApplyProportion");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("借款平台和申请借款平台比例");
			mcamAutoDecisionRecord.setRuleDescription("最小值为：" + ruleLoanApplyProportion);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(loanApplyProportionObj != null){
				double loanApplyProportion = (double)autoDecisionData.get("loanApplyProportion");
				mcamAutoDecisionRecord.setUserDetail("用户借款平台和申请借款平台比例为：" + loanApplyProportion);
				String status = loanApplyProportion < ruleLoanApplyProportion ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleLoanApplyProportionDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户借款平台和申请借款平台比例为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		
		//近七天被叫且联系人不在通讯录里的次数
		McsmRevealConfigureAppDTO rule7dCalledNolinkCountDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("rule7dCalledNolinkCount");
		if(rule7dCalledNolinkCountDto != null){
			int rule7dCalledNolinkCount = Integer.parseInt(rule7dCalledNolinkCountDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object d7CalledNolinkCountObj = autoDecisionData.get("d7CalledNolinkCount");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("近七天被叫且联系人不在通讯录里的次数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + rule7dCalledNolinkCount);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(d7CalledNolinkCountObj != null){
				int d7CalledNolinkCount = (int)autoDecisionData.get("d7CalledNolinkCount");
				mcamAutoDecisionRecord.setUserDetail("用户近七天被叫且联系人不在通讯录里的次数为：" + d7CalledNolinkCount);
				String status = d7CalledNolinkCount >= rule7dCalledNolinkCount ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(rule7dCalledNolinkCountDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户近七天被叫且联系人不在通讯录里的次数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 短信出现逾期字样的次数
		McsmRevealConfigureAppDTO ruleOverdueMessageCountDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleOverdueMessageCount");
		if(ruleOverdueMessageCountDto != null){
			int ruleOverdueMessageCount = Integer.parseInt(ruleOverdueMessageCountDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object overdueMessageCountObj = autoDecisionData.get("overdueMessageCount");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("短信出现逾期字样的次数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleOverdueMessageCount);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(overdueMessageCountObj != null){
				int overdueMessageCount = (int)autoDecisionData.get("overdueMessageCount");
				mcamAutoDecisionRecord.setUserDetail("用户短信出现逾期字样的次数为：" + overdueMessageCount);
				String status = overdueMessageCount >= ruleOverdueMessageCount ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleOverdueMessageCountDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户短信出现逾期字样的次数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 12599（语音信箱）被叫出现次数
		McsmRevealConfigureAppDTO rule12599CalledCountDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("rule12599CalledCount");
		if(rule12599CalledCountDto != null){
			int rule12599CalledCount = Integer.parseInt(rule12599CalledCountDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object called12599CountObj = autoDecisionData.get("called12599Count");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("12599（语音信箱）被叫出现次数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + rule12599CalledCount);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(called12599CountObj != null){
				int called12599Count = (int)autoDecisionData.get("called12599Count");
				mcamAutoDecisionRecord.setUserDetail("用户12599（语音信箱）被叫出现次数为：" + called12599Count);
				String status = called12599Count >= rule12599CalledCount ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(rule12599CalledCountDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户12599（语音信箱）被叫出现次数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 直接联系人中黑名单人数
		McsmRevealConfigureAppDTO ruleDirectLinkmanBlackNumDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleDirectLinkmanBlackNum");
		if(ruleDirectLinkmanBlackNumDto != null){
			int ruleDirectLinkmanBlackNum = Integer.parseInt(ruleDirectLinkmanBlackNumDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object directLinkmanBlackNumObj = autoDecisionData.get("directLinkmanBlackNum");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("直接联系人中黑名单人数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleDirectLinkmanBlackNum);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(directLinkmanBlackNumObj != null){
				int directLinkmanBlackNum = (int)autoDecisionData.get("directLinkmanBlackNum");
				mcamAutoDecisionRecord.setUserDetail("用户直接联系人中黑名单人数为：" + directLinkmanBlackNum);
				String status = directLinkmanBlackNum >= ruleDirectLinkmanBlackNum ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleDirectLinkmanBlackNumDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户直接联系人中黑名单人数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 间接联系人中黑名单人数
		McsmRevealConfigureAppDTO ruleIndirectLinkmanBlackNumDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleIndirectLinkmanBlackNum");
		if(ruleIndirectLinkmanBlackNumDto != null){
			int ruleIndirectLinkmanBlackNum = Integer.parseInt(ruleIndirectLinkmanBlackNumDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object indirectLinkmanBlackNumObj = autoDecisionData.get("indirectLinkmanBlackNum");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("间接联系人中黑名单人数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleIndirectLinkmanBlackNum);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(indirectLinkmanBlackNumObj != null){
				int indirectLinkmanBlackNum = (int)autoDecisionData.get("indirectLinkmanBlackNum");
				mcamAutoDecisionRecord.setUserDetail("用户间接联系人中黑名单人数为：" + indirectLinkmanBlackNum);
				String status = indirectLinkmanBlackNum >= ruleIndirectLinkmanBlackNum ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleIndirectLinkmanBlackNumDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户间接联系人中黑名单人数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 引起黑名单的直接联系人数量
		McsmRevealConfigureAppDTO ruleCauseDirectLinkmanNumDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleCauseDirectLinkmanNum");
		if(ruleCauseDirectLinkmanNumDto != null){
			int ruleCauseDirectLinkmanNum = Integer.parseInt(ruleCauseDirectLinkmanNumDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object causeDirectLinkmanNumObj = autoDecisionData.get("causeDirectLinkmanNum");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("引起黑名单的直接联系人数量");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleCauseDirectLinkmanNum);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(causeDirectLinkmanNumObj != null){
				int causeDirectLinkmanNum = (int)autoDecisionData.get("causeDirectLinkmanNum");
				mcamAutoDecisionRecord.setUserDetail("用户引起黑名单的直接联系人数量为：" + causeDirectLinkmanNum);
				String status = causeDirectLinkmanNum >= ruleCauseDirectLinkmanNum ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleCauseDirectLinkmanNumDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户引起黑名单的直接联系人数量为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		
		// 直接联系人中引起间接黑名单占比
		McsmRevealConfigureAppDTO ruleDirectCauseIndirectRateDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleDirectCauseIndirectRate");
		if(ruleDirectCauseIndirectRateDto != null){
			double ruleDirectCauseIndirectRate = Double.parseDouble(ruleDirectCauseIndirectRateDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object directCauseIndirectRateObj = autoDecisionData.get("directCauseIndirectRate");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("直接联系人中引起间接黑名单占比");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleDirectCauseIndirectRate);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(directCauseIndirectRateObj != null){
				double directCauseIndirectRate = (double)autoDecisionData.get("directCauseIndirectRate");
				mcamAutoDecisionRecord.setUserDetail("用户直接联系人中引起间接黑名单占比为：" + directCauseIndirectRate);
				String status = directCauseIndirectRate >= ruleDirectCauseIndirectRate ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleDirectCauseIndirectRateDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户直接联系人中引起间接黑名单占比为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 人物画像风险指数
		McsmRevealConfigureAppDTO ruleCharacterPortraitRiskDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleCharacterPortraitRisk");
		if(ruleCharacterPortraitRiskDto != null){
			int ruleCharacterPortraitRisk = Integer.parseInt(ruleCharacterPortraitRiskDto.getConfigValue());
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object characterPortraitRiskObj = autoDecisionData.get("characterPortraitRisk");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("人物画像风险指数");
			mcamAutoDecisionRecord.setRuleDescription("最大值为：" + ruleCharacterPortraitRisk);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(characterPortraitRiskObj != null){
				int characterPortraitRisk = (int)autoDecisionData.get("characterPortraitRisk");
				mcamAutoDecisionRecord.setUserDetail("用户人物画像风险指数为：" + characterPortraitRisk);
				String status = characterPortraitRisk >= ruleCharacterPortraitRisk ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleCharacterPortraitRiskDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户人物画像风险指数为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		
		// 禁用APP名称
		McsmRevealConfigureAppDTO ruleProhibitAppNameDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleProhibitAppName");
		if(ruleProhibitAppNameDto != null){
			String ruleProhibitAppName = ruleProhibitAppNameDto.getConfigValue();
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object prohibitAppNameObj = autoDecisionData.get("prohibitAppName");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("禁用APP名称");
			mcamAutoDecisionRecord.setRuleDescription("禁用APP名称为：" + ruleProhibitAppName);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(prohibitAppNameObj != null){
				String prohibitAppName = autoDecisionData.get("prohibitAppName").toString();
				mcamAutoDecisionRecord.setUserDetail("用户APP列表为：" + prohibitAppName);
				String status = "0";
				List<String> prohibitApps = Arrays.asList(ruleProhibitAppName.split("\\|"));
				for (String appName : prohibitApps) {
					if(prohibitAppName.contains(appName)){
						status = "1";
						break;
					}
				}
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleProhibitAppNameDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户APP列表为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 大数据风险模型结果
		McsmRevealConfigureAppDTO ruleRiskModelResultDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleRiskModelResult");
		if(ruleRiskModelResultDto != null){
			String ruleRiskModelResult = ruleRiskModelResultDto.getConfigValue();
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object riskModelResultObj = autoDecisionData.get("riskModelResult");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("风险模型结果");
			mcamAutoDecisionRecord.setRuleDescription("风险结果禁止为：" + ruleRiskModelResult);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(riskModelResultObj != null){
				String riskModelResult = autoDecisionData.get("riskModelResult").toString();
				mcamAutoDecisionRecord.setUserDetail("用户风险模型结果为：" + riskModelResult);
				String status = StrUtil.equals(ruleRiskModelResult.trim(), riskModelResult.trim()) ? "1" : "0";
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleRiskModelResultDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户风险模型为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		// 禁用注册设备来源关键字
		McsmRevealConfigureAppDTO ruleProhibitUserAgentDto = (McsmRevealConfigureAppDTO) ruleMap.getObject("ruleProhibitUserAgent");
		if(ruleProhibitUserAgentDto != null){
			String ruleProhibitUserAgent = ruleProhibitUserAgentDto.getConfigValue();
			McamAutoDecisionRecord mcamAutoDecisionRecord = new McamAutoDecisionRecord();
			//配置文件有设定值
			Object userAgentObj = autoDecisionData.get("userAgent");
			mcamAutoDecisionRecord.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionRecord.setRuleName("禁用注册设备来源关键字");
			mcamAutoDecisionRecord.setRuleDescription("禁用注册设备来源关键字为：" + ruleProhibitUserAgent);
			mcamAutoDecisionRecord.setCreatedBy("sys");
			mcamAutoDecisionRecord.setUpdatedBy("sys");
			if(userAgentObj != null){
				String userAgent = autoDecisionData.get("userAgent").toString();
				UserAgentDTO userAgentDTO = acUserAgentMappingService.dealUserAgent(userAgent);
				mcamAutoDecisionRecord.setUserDetail("用户注册设备来源为：" + (userAgentDTO == null ? "未知" : 
					StrUtil.format("设备：{}，浏览器：{}", userAgentDTO.getDevice(), userAgentDTO.getBrowser())));
				String status = "0";
				List<String>  prohibitUserAgents = Arrays.asList(ruleProhibitUserAgent.split("\\|"));
				if(userAgentDTO != null){
					for (String prohibitUserAgent : prohibitUserAgents) {
						if(StrUtil.equalsIgnoreCase(userAgentDTO.getDevice(), prohibitUserAgent)
								|| StrUtil.equalsIgnoreCase(userAgentDTO.getBrowser(), prohibitUserAgent)){
							status = "1";
							break;
						}
					}
				}
				mcamAutoDecisionRecord.setStatus(status);
				if("1".equals(status)){
					rejectNum ++;
					// 是否自动拒绝
					if(ruleProhibitUserAgentDto.getConfigTemp1() == 1){
						result = false;
					}
				}
			}else{
				mcamAutoDecisionRecord.setUserDetail("用户注册设备来源为(未知)");
			}
			decisionRecordList.add(mcamAutoDecisionRecord);
		}
		
		McamAutoDecisionWithBLOBs mcamAutoDecisionWithBLOBs = mcamAutoDecisionMapper.selectByLoanId(mcamLoanApplyInfo.getLoanId());
		if(mcamAutoDecisionWithBLOBs == null){
			mcamAutoDecisionWithBLOBs = new McamAutoDecisionWithBLOBs();
			mcamAutoDecisionWithBLOBs.setCreatedBy("sys");
			mcamAutoDecisionWithBLOBs.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionWithBLOBs.setRejectNum(rejectNum);
			String status = rejectNum == 0 ? "0" : "1";
			mcamAutoDecisionWithBLOBs.setStatus(status);
			mcamAutoDecisionWithBLOBs.setType("1");
			mcamAutoDecisionWithBLOBs.setUpdatedBy("sys");
			mcamAutoDecisionWithBLOBs.setRule(JSONObject.toJSONString(ruleMap));
			mcamAutoDecisionWithBLOBs.setRuleParam(autoDecisionData.toString());
			mcamAutoDecisionMapper.insertSelective(mcamAutoDecisionWithBLOBs);
		}else{
			mcamAutoDecisionWithBLOBs.setLoanId(mcamLoanApplyInfo.getLoanId());
			mcamAutoDecisionWithBLOBs.setRejectNum(rejectNum);
			String status = rejectNum == 0 ? "0" : "1";
			mcamAutoDecisionWithBLOBs.setStatus(status);
			mcamAutoDecisionWithBLOBs.setType("1");
			mcamAutoDecisionWithBLOBs.setRule(JSONObject.toJSONString(ruleMap));
			mcamAutoDecisionWithBLOBs.setRuleParam(autoDecisionData.toString());
			mcamAutoDecisionWithBLOBs.setUpdatedDate(new Date());
			mcamAutoDecisionMapper.updateByPrimaryKeyWithBLOBs(mcamAutoDecisionWithBLOBs);
		}
		saveAutoDecisionDetail(mcamAutoDecisionWithBLOBs, decisionRecordList);
		
		return result;
	}
	
	/**
	 * 
	* @Title: saveAutoDecisionDetail 
	* @Description:保存客户决策详细  
	* @param mcamAutoDecisionWithBLOBs
	* @param decisionRecordList       
	* @author 李瑶
	* @date 2018年10月9日 上午9:22:41
	 */
	private void saveAutoDecisionDetail(McamAutoDecisionWithBLOBs mcamAutoDecisionWithBLOBs,List<McamAutoDecisionRecord> decisionRecordList ){
		mcamAutoDecisionRecordMapper.deleteByLoanId(mcamAutoDecisionWithBLOBs.getLoanId());
		for(McamAutoDecisionRecord mcamAutoDecisionRecord : decisionRecordList){
			mcamAutoDecisionRecord.setDecisionId(mcamAutoDecisionWithBLOBs.getId());
			mcamAutoDecisionRecordMapper.insertSelective(mcamAutoDecisionRecord);
		}
	}

	
	
	private DataRow geRuleMap(){
		DataRow data = new DataRow();
		//查询决策值
		McsmRevealConfigureAppDTO param = new McsmRevealConfigureAppDTO();
		param.setConfigType(2);
		List<McsmRevealConfigureAppDTO> configList = mcsmRevealConfigureAppDao.queryConfigList(param);
		MarvelsLogUtil.getInstance().info("查询决策值列表：" + JSONObject.toJSONString(configList));
		Map<String, McsmRevealConfigureAppDTO> decisionRule = new HashMap<String, McsmRevealConfigureAppDTO>();
		for (McsmRevealConfigureAppDTO dto : configList) {
			decisionRule.put(dto.getConfigKey(), dto);
		}
		
		//魔蝎拉取的蚂蚁芝麻分最小值
		McsmRevealConfigureAppDTO ruleAntScoreMin = decisionRule.get("rule.ant.score.min");
		if(ruleAntScoreMin != null && ruleAntScoreMin.getConfigValue() != null && ruleAntScoreMin.getState() == 0){
			data.set("ruleAntScoreMin", ruleAntScoreMin);
		}
		
		//任务画像风险指数
		McsmRevealConfigureAppDTO rulePortraitMax = decisionRule.get("rule.portrait.max");
		if(rulePortraitMax != null && rulePortraitMax.getConfigValue() != null && rulePortraitMax.getState() == 0){
			data.set("rulePortraitMax", rulePortraitMax);
		}
		
		//年龄最大值
		McsmRevealConfigureAppDTO ruleAgeMax = decisionRule.get("rule.age.max");
		if(ruleAgeMax != null && ruleAgeMax.getConfigValue() != null && ruleAgeMax.getState() == 0){
			data.set("ruleAgeMax", ruleAgeMax);
		}
		
		//年龄最小值
		McsmRevealConfigureAppDTO ruleAgeMin = decisionRule.get("rule.age.min");
		if(ruleAgeMin != null && ruleAgeMin.getConfigValue() != null && ruleAgeMin.getState() == 0){
			data.set("ruleAgeMin", ruleAgeMin);
		}
		
		//联系人中黑名单占比
		McsmRevealConfigureAppDTO ruleContactForbidenPercent = decisionRule.get("rule.contact.forbiden.percent");
		if(ruleContactForbidenPercent != null && ruleContactForbidenPercent.getConfigValue() != null && ruleContactForbidenPercent.getState() == 0){
			data.set("ruleContactForbidenPercent", ruleContactForbidenPercent);
		}
		
		//近一月手机关机次数
		McsmRevealConfigureAppDTO ruleClosePhoneDaysMax = decisionRule.get("rule.close.phone.days.max");
		if(ruleClosePhoneDaysMax != null && ruleClosePhoneDaysMax.getConfigValue() != null && ruleClosePhoneDaysMax.getState() == 0){
			data.set("ruleClosePhoneDaysMax", ruleClosePhoneDaysMax);
		}
		
		//身份证所在省份禁止进件
		McsmRevealConfigureAppDTO ruleIdcardLimitProvince = decisionRule.get("rule.idcard.limit.privince");
		if(ruleIdcardLimitProvince != null && ruleIdcardLimitProvince.getConfigValue() != null && ruleIdcardLimitProvince.getState() == 0){
			data.set("ruleIdcardLimitProvince", ruleIdcardLimitProvince);
		}
		
		//近三月催收电话通话次数
		McsmRevealConfigureAppDTO ruleCollectionTimes = decisionRule.get("rule.collection_times");
		if(ruleCollectionTimes != null && ruleCollectionTimes.getConfigValue() != null && ruleCollectionTimes.getState() == 0){
			data.set("ruleCollectionTimes", ruleCollectionTimes);
		}
		
		//逾期平台数
		McsmRevealConfigureAppDTO ruleOverduePlatNum = decisionRule.get("rule.overdue.plat.num");
		if(ruleOverduePlatNum != null && ruleOverduePlatNum.getConfigValue() != null && ruleOverduePlatNum.getState() == 0){
			data.set("ruleOverduePlatNum", ruleOverduePlatNum);
		}
		
		//手机入网时长
		McsmRevealConfigureAppDTO rulePhoneIntNetTime = decisionRule.get("rule.phone.int.net.time");
		if(rulePhoneIntNetTime != null && rulePhoneIntNetTime.getConfigValue() != null && rulePhoneIntNetTime.getState() == 0){
			data.set("rulePhoneIntNetTime", rulePhoneIntNetTime);
		}
		
		//运营商姓名和身份证姓名是否一致
		McsmRevealConfigureAppDTO ruleYysSameName = decisionRule.get("rule.yys.same.name");
		if(ruleYysSameName != null && ruleYysSameName.getConfigValue() != null && ruleYysSameName.getState() == 0){
			data.set("ruleYysSameName", ruleYysSameName);
		}
		
		//通讯录联系人最小数
		McsmRevealConfigureAppDTO ruleContactNumMin = decisionRule.get("rule.contact.num.min");
		if(ruleContactNumMin != null && ruleContactNumMin.getConfigValue() != null && ruleContactNumMin.getState() == 0){
			data.set("ruleContactNumMin", ruleContactNumMin);
		}
		
		//短信模型评分最小值
		McsmRevealConfigureAppDTO ruleMsgScoreMin = decisionRule.get("rule.msg.score.min");
		if(ruleMsgScoreMin != null && ruleMsgScoreMin.getConfigValue() != null && ruleMsgScoreMin.getState() == 0){
			data.set("ruleMsgScoreMin", ruleMsgScoreMin);
		}
		
		//近1月申请借款平台数
		McsmRevealConfigureAppDTO ruleLoanPlatformCount1m = decisionRule.get("rule.loan.platform.count.1m");
		if(ruleLoanPlatformCount1m != null && ruleLoanPlatformCount1m.getConfigValue() != null && ruleLoanPlatformCount1m.getState() == 0){
			data.set("ruleLoanPlatformCount1m", ruleLoanPlatformCount1m);
		}
		
		//近3月申请借款平台数
		McsmRevealConfigureAppDTO ruleLoanPlatformCount3m = decisionRule.get("rule.loan.platform.count.3m");
		if(ruleLoanPlatformCount3m != null && ruleLoanPlatformCount3m.getConfigValue() != null && ruleLoanPlatformCount3m.getState() == 0){
			data.set("ruleLoanPlatformCount3m", ruleLoanPlatformCount3m);
		}
		
		//近6月申请借款平台数
		McsmRevealConfigureAppDTO ruleLoanPlatformCount6m = decisionRule.get("rule.loan.platform.count.6m");
		if(ruleLoanPlatformCount6m != null && ruleLoanPlatformCount6m.getConfigValue() != null && ruleLoanPlatformCount6m.getState() == 0){
			data.set("ruleLoanPlatformCount6m", ruleLoanPlatformCount6m);
		}
		
		//申请借款平台数
		McsmRevealConfigureAppDTO ruleLoanPlatformCount = decisionRule.get("rule.loan.platform.count");
		if(ruleLoanPlatformCount != null && ruleLoanPlatformCount.getConfigValue() != null && ruleLoanPlatformCount.getState() == 0){
			data.set("ruleLoanPlatformCount", ruleLoanPlatformCount);
		}
		
		//黑中介分数
		McsmRevealConfigureAppDTO ruleAgencyScore = decisionRule.get("rule.agency.score");
		if(ruleAgencyScore != null && ruleAgencyScore.getConfigValue() != null && ruleAgencyScore.getState() == 0){
			data.set("ruleAgencyScore", ruleAgencyScore);
		}
		
		//查询过该用户的相关企业数量（姓名+身份证+电话号码）
		McsmRevealConfigureAppDTO ruleSearchedOrgCnt = decisionRule.get("rule.searched.org.cnt");
		if(ruleSearchedOrgCnt != null && ruleSearchedOrgCnt.getConfigValue() != null && ruleSearchedOrgCnt.getState() == 0){
			data.set("ruleSearchedOrgCnt", ruleSearchedOrgCnt);
		}
		
		//电话号码注册过的相关企业数量
		McsmRevealConfigureAppDTO ruleRegisterOrgCnt = decisionRule.get("rule.register.org.cnt");
		if(ruleRegisterOrgCnt != null && ruleRegisterOrgCnt.getConfigValue() != null && ruleRegisterOrgCnt.getState() == 0){
			data.set("ruleRegisterOrgCnt", ruleRegisterOrgCnt);
		}
		
		//上海资信当前逾期贷款合同总额
		McsmRevealConfigureAppDTO ruleLoanOverdueTotal = decisionRule.get("rule.loan.overdue.total");
		if(ruleLoanOverdueTotal != null && ruleLoanOverdueTotal.getConfigValue() != null && ruleLoanOverdueTotal.getState() == 0){
			data.set("ruleLoanOverdueTotal", ruleLoanOverdueTotal);
		}
		
		//上海资信近24个月逾期月数
		McsmRevealConfigureAppDTO ruleB24OverdueMonths = decisionRule.get("rule.b24.overdue.months");
		if(ruleB24OverdueMonths != null && ruleB24OverdueMonths.getConfigValue() != null && ruleB24OverdueMonths.getState() == 0){
			data.set("ruleB24OverdueMonths", ruleB24OverdueMonths);
		}
		
		//有盾用户使用手机号数
		McsmRevealConfigureAppDTO ruleMobileCount = decisionRule.get("rule.mobile.count");
		if(ruleMobileCount != null && ruleMobileCount.getConfigValue() != null && ruleMobileCount.getState() == 0){
			data.set("ruleMobileCount", ruleMobileCount);
		}
		
		//有盾用户关联银行卡数
		McsmRevealConfigureAppDTO ruleBankcardCount = decisionRule.get("rule.bankcard.count");
		if(ruleBankcardCount != null && ruleBankcardCount.getConfigValue() != null && ruleBankcardCount.getState() == 0){
			data.set("ruleBankcardCount", ruleBankcardCount);
		}
		
		//有盾设备关联用户数
		McsmRevealConfigureAppDTO ruleLinkUserCount = decisionRule.get("rule.link.user.count");
		if(ruleLinkUserCount != null && ruleLinkUserCount.getConfigValue() != null && ruleLinkUserCount.getState() == 0){
			data.set("ruleLinkUserCount", ruleLinkUserCount);
		}
		
		//有盾身份特质
		McsmRevealConfigureAppDTO ruleUserFeatureType = decisionRule.get("rule.user.feature.type");
		if(ruleUserFeatureType != null && ruleUserFeatureType.getConfigValue() != null && ruleUserFeatureType.getState() == 0){
			data.set("ruleUserFeatureType", ruleUserFeatureType);
		}
		
		//有盾风险等级
		McsmRevealConfigureAppDTO ruleRiskEvaluation = decisionRule.get("rule.risk.evaluation");
		if(ruleRiskEvaluation != null && ruleRiskEvaluation.getConfigValue() != null && ruleRiskEvaluation.getState() == 0){
			data.set("ruleRiskEvaluation", ruleRiskEvaluation);
		}
		
		//共享黑名单数
		McsmRevealConfigureAppDTO ruleBlackPlatCount = decisionRule.get("rule.black.plat.count");
		if(ruleBlackPlatCount != null && ruleBlackPlatCount.getConfigValue() != null && ruleBlackPlatCount.getState() == 0){
			data.set("ruleBlackPlatCount", ruleBlackPlatCount);
		}
		
		// 近6个月前3通话次数总和
		McsmRevealConfigureAppDTO ruleCall6mTop3Number = decisionRule.get("rule.call.6m.top3.number");
		if(ruleCall6mTop3Number != null && ruleCall6mTop3Number.getConfigValue() != null && ruleCall6mTop3Number.getState() == 0){
			data.set("ruleCall6mTop3Number", ruleCall6mTop3Number);
		}
		
		// 通话次数第10位次数
		McsmRevealConfigureAppDTO ruleCallTenthNumber = decisionRule.get("rule.call.tenth.number");
		if(ruleCallTenthNumber != null && ruleCallTenthNumber.getConfigValue() != null && ruleCallTenthNumber.getState() == 0){
			data.set("ruleCallTenthNumber", ruleCallTenthNumber);
		}
		
		// 近3个月前5通话总和
		McsmRevealConfigureAppDTO ruleCall3mTop5Number = decisionRule.get("rule.call.3m.top5.number");
		if(ruleCall3mTop5Number != null && ruleCall3mTop5Number.getConfigValue() != null && ruleCall3mTop5Number.getState() == 0){
			data.set("ruleCall3mTop5Number", ruleCall3mTop5Number);
		}
		
		// 通讯录没备注号码个数
		McsmRevealConfigureAppDTO ruleLinkmansRemarkEmptyNumber = decisionRule.get("rule.linkmans.remark.empty.number");
		if(ruleLinkmansRemarkEmptyNumber != null && ruleLinkmansRemarkEmptyNumber.getConfigValue() != null && ruleLinkmansRemarkEmptyNumber.getState() == 0){
			data.set("ruleLinkmansRemarkEmptyNumber", ruleLinkmansRemarkEmptyNumber);
		}
		
		// 总借款平台和还款平台差值
		McsmRevealConfigureAppDTO ruleLoanRepaymentDifference = decisionRule.get("rule.loan.repayment.difference");
		if(ruleLoanRepaymentDifference != null && ruleLoanRepaymentDifference.getConfigValue() != null && ruleLoanRepaymentDifference.getState() == 0){
			data.set("ruleLoanRepaymentDifference", ruleLoanRepaymentDifference);
		}
		
		// 借款平台和申请借款平台比例
		McsmRevealConfigureAppDTO ruleLoanApplyProportion = decisionRule.get("rule.loan.apply.proportion");
		if(ruleLoanApplyProportion != null && ruleLoanApplyProportion.getConfigValue() != null && ruleLoanApplyProportion.getState() == 0){
			data.set("ruleLoanApplyProportion", ruleLoanApplyProportion);
		}
		
		// 近七天被叫且联系人不在通讯录里的次数
		McsmRevealConfigureAppDTO rule7dCalledNolinkCount = decisionRule.get("rule.7d.called.nolink.count");
		if(rule7dCalledNolinkCount != null && rule7dCalledNolinkCount.getConfigValue() != null && rule7dCalledNolinkCount.getState() == 0){
			data.set("rule7dCalledNolinkCount", rule7dCalledNolinkCount);
		}
		
		// 短信出现逾期字样的次数
		McsmRevealConfigureAppDTO ruleOverdueMessageCount = decisionRule.get("rule.overdue.message.count");
		if(ruleOverdueMessageCount != null && ruleOverdueMessageCount.getConfigValue() != null && ruleOverdueMessageCount.getState() == 0){
			data.set("ruleOverdueMessageCount", ruleOverdueMessageCount);
		}
		
		//12599（语音信箱）被叫出现次数
		McsmRevealConfigureAppDTO rule12599CalledCount = decisionRule.get("rule.12599.called.count");
		if(rule12599CalledCount != null && rule12599CalledCount.getConfigValue() != null && rule12599CalledCount.getState() == 0){
			data.set("rule12599CalledCount", rule12599CalledCount);
		}
		
		// 直接联系人中黑名单人数
		McsmRevealConfigureAppDTO ruleDirectLinkmanBlackNum = decisionRule.get("rule.direct.linkman.black.num");
		if(ruleDirectLinkmanBlackNum != null && ruleDirectLinkmanBlackNum.getConfigValue() != null && ruleDirectLinkmanBlackNum.getState() == 0){
			data.set("ruleDirectLinkmanBlackNum", ruleDirectLinkmanBlackNum);
		}
		
		// 间接联系人中黑名单人数
		McsmRevealConfigureAppDTO ruleIndirectLinkmanBlackNum = decisionRule.get("rule.indirect.linkman.black.num");
		if(ruleIndirectLinkmanBlackNum != null && ruleIndirectLinkmanBlackNum.getConfigValue() != null && ruleIndirectLinkmanBlackNum.getState() == 0){
			data.set("ruleIndirectLinkmanBlackNum", ruleIndirectLinkmanBlackNum);
		}
		
		// 引起黑名单的直接联系人数量
		McsmRevealConfigureAppDTO ruleCauseDirectLinkmanNum = decisionRule.get("rule.cause.direct.linkman.num");
		if(ruleCauseDirectLinkmanNum != null && ruleCauseDirectLinkmanNum.getConfigValue() != null && ruleCauseDirectLinkmanNum.getState() == 0){
			data.set("ruleCauseDirectLinkmanNum", ruleCauseDirectLinkmanNum);
		}
		
		// 直接联系人中引起间接黑名单占比
		McsmRevealConfigureAppDTO ruleDirectCauseIndirectRate = decisionRule.get("rule.direct.cause.indirect.rate");
		if(ruleDirectCauseIndirectRate != null && ruleDirectCauseIndirectRate.getConfigValue() != null && ruleDirectCauseIndirectRate.getState() == 0){
			data.set("ruleDirectCauseIndirectRate", ruleDirectCauseIndirectRate);
		}
		
		// 人物画像风险指数
		McsmRevealConfigureAppDTO ruleCharacterPortraitRisk = decisionRule.get("rule.character.portrait.risk");
		if(ruleCharacterPortraitRisk != null && ruleCharacterPortraitRisk.getConfigValue() != null && ruleCharacterPortraitRisk.getState() == 0){
			data.set("ruleCharacterPortraitRisk", ruleCharacterPortraitRisk);
		}
		
		// 禁用apps名称
		McsmRevealConfigureAppDTO ruleProhibitAppName = decisionRule.get("rule.prohibit.app.name");
		if(ruleProhibitAppName != null && ruleProhibitAppName.getConfigValue() != null && ruleProhibitAppName.getState() == 0){
			data.set("ruleProhibitAppName", ruleProhibitAppName);
		}
		
		// 风险模型结果
		McsmRevealConfigureAppDTO ruleRiskModelResult = decisionRule.get("rule.risk.model.result");
		if(ruleRiskModelResult != null && ruleRiskModelResult.getConfigValue() != null && ruleRiskModelResult.getState() == 0){
			data.set("ruleRiskModelResult", ruleRiskModelResult);
		}
		
		// 禁用注册来源关键字（User-Agent）
		McsmRevealConfigureAppDTO ruleProhibitUserAgent = decisionRule.get("rule.prohibit.user.agent");
		if(ruleProhibitUserAgent != null && ruleProhibitUserAgent.getConfigValue() != null && ruleProhibitUserAgent.getState() == 0){
			data.set("ruleProhibitUserAgent", ruleProhibitUserAgent);
		}
		
		MarvelsLogUtil.getInstance().info("决策值解析后：" + JSONObject.toJSONString(data));
		return data;

	}
	
	/**
	 * 
	* @Title: getThirdData 
	* @Description:拉取第三方数据  
	* @param loanId
	* @param name
	* @param idNum
	* @param phone       
	* @author 李瑶
	* @date 2018年10月20日 下午3:07:43
	 */
	private Map<String, Object> getThirdData(McamLoanApplyInfoDTO mcamLoanApplyInfo){
		shangHaiZiXinInfo(mcamLoanApplyInfo.getLoanId(), mcamLoanApplyInfo.getCustName(), mcamLoanApplyInfo.getCustCardNo(), mcamLoanApplyInfo.getMobileNo());
		youDunInfo(mcamLoanApplyInfo.getLoanId(), mcamLoanApplyInfo.getCustCardNo());
		predictMessage(mcamLoanApplyInfo.getLoanId(), mcamLoanApplyInfo.getCustCardNo(), mcamLoanApplyInfo.getMobileNo());
		// 调用大数据风险模型
		Map<String, Object> autoDecisionData = getDecisionData(mcamLoanApplyInfo);
		EdcRiskModel riskModel = riskModel(autoDecisionData);
		if(riskModel != null){
			autoDecisionData.put("riskModelResult", riskModel.getPrediction());
		}
		return autoDecisionData;
	}
	
	
	/**
	 * 调用上海资信接口
	 */
	private void shangHaiZiXinInfo(String loanId,String name,String idNum ,String phone) {
		MarvelsLogUtil.getInstance().info("决策调用上海资信接口，传入参数===="+"loanId=="+loanId+"=name="+name+"=idNum="+idNum);
		try {
			Map<String,String> mapin=new HashMap<String,String>();
			mapin.put("name", name);
			mapin.put("certno", idNum);
			mapin.put("loanId", loanId);
			/*mapin.put("createdB", "sys");
			mapin.put("updatedBy", "sys");
			mapin.put("isBaiMi", "bm");*/
			mapin.put("phone", phone);
			//shangHaiLogInService.shzxPeronalInfo(mapin);
			shangHaiLogInService.queryNewDirect(mapin);
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("决策调用上海资信接口时发生异常===="+e);
		}
	}
	
	/**
	 * 
	* @Title: youDunInfo 
	* @Description:调用有盾数据  
	* @param loanId
	* @param idNum       
	* @author 李瑶
	* @date 2018年11月2日 下午5:44:54
	 */
	private void youDunInfo(String loanId,String idNum) {
		MarvelsLogUtil.getInstance().info("决策调用有盾接口，传入参数===="+"loanId=="+loanId+"=idNum="+idNum);
		try {
			Map<String, String> param = new HashMap<>();
			param.put("loanId", loanId);
			param.put("idNo", idNum);
			ydservice.queryUserPortrait(param);
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("决策调用有盾接口时发生异常===="+e);
		}
	}
	
	/**
	 * 调用短信模型分
	 * @param loanId
	 * @param idNum
	 * @param mobile
	 */
	private void predictMessage(String loanId, String idCard, String mobile) {
		try {
			String againLoanId =  thirdCreditReportService.getThirdLoanId(loanId);
			MarvelsLogUtil.getInstance().info("决策调用短信模型分，传入参数====" + "loanId==" + loanId + ",againLoanId=" + againLoanId + ",idCard=" + idCard + ",mobile=" + mobile);
			Map<String, String> param = new HashMap<>();
			param.put("loanId", loanId);
			param.put("idCard", idCard);
			param.put("mobile", mobile);
			ApiResponse<EdcMessagePredictInfo>  result = predictMessageService.excutePredictMessage(param);
			MarvelsLogUtil.getInstance().info("决策调用短信模型分，结果" + JSONObject.toJSONString(result));
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("决策调用短信模型分异常===="+e);
		}
	}
	
	private EdcRiskModel riskModel(Map<String, Object> param) {
		try {
			Object loanId = param.get("loanId");
			MarvelsLogUtil.getInstance().info("决策调用风险模型，传入参数====" + "loanId==" + loanId);
			ApiResponse<EdcRiskModel> result = predictMessageService.excuteRiskModel(param);
			MarvelsLogUtil.getInstance().info("决策调用风险模型，结果" + JSONObject.toJSONString(result));
			return result.getData();
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error("决策调用风险模型异常===="+e);
			return null;
		}
	}
	
//	/**
//	 * 
//	* @Title: tDInfo 
//	* @Description:同盾  
//	* @param loanId
//	* @param name
//	* @param idNum
//	* @param phone       
//	* @author 李瑶
//	* @date 2018年10月20日 下午3:07:27
//	 */
//	private void tDInfo(String loanId,String name,String idNum ,String phone){
//			Map<String, Object> map = new HashMap<String, Object>();
//			map.put("ip_address", "127.0.0.1");
//			ApiResponse apiResponse=null;
//			map.put("loanId", loanId);
//			map.put("account_name", name);
//			map.put("account_mobile", phone);
//			map.put("id_number",idNum);
//			MarvelsLogUtil.getInstance().info("==========同盾决策接口请求参数:" + JSONObject.fromObject(map));
//			try{
//				apiResponse=tongDunService.TdDecision(map);
//			}catch(Exception e){
//				MarvelsLogUtil.getInstance().error("=====tdDecision=====", e);
//				MarvelsLogUtil.getInstance().info("==========同盾决策接口调用异常");
//				return;
//			}
//			MarvelsLogUtil.getInstance().info("==========同盾决策接口调用结果:"+JSONObject.fromObject(apiResponse));
//	}
//	
//	/**
//	 * 
//	* @Title: getBrOneCreditData 
//	* @Description:调用百融一卡贷数据         
//	* @author 李瑶
//	* @date 2018年10月20日 下午3:14:05
//	 */
//	private void getBrOneCreditData(String loanId,String name,String idNum ,String phone,String receiveAcct,String productType){
//		MarvelsLogUtil.getInstance().info("=================调用一卡贷打包所有请求开始===============loanId:" + loanId);
//		
//		JSONObject json = new JSONObject();
//
//		json.put("idNumber", idNum);
//		json.put("mobile", phone);
//		json.put("name", name);
//		json.put("bankId",name);
//		json.put("productType", productType);
//		MarvelsLogUtil.getInstance().info("=================一卡贷打包所有请求参数===============loanId:"+loanId+",参数" +json);
//		ApiResponse apiResponse = oneCreditCardService.packAllInterfaceInfo(json, SerialNumCreater.creater("BR", loanId), loanId, "approve");
//		MarvelsLogUtil.getInstance().info("=================一卡贷打包所有请求结束===============loanId:" + loanId+"返回参数错误码:"+JSONObject.fromObject(apiResponse));
//		
//		
//	}
	

	
	public static void main(String[] args) throws Exception {
		double b = 0.1;
		int i=0;
		System.out.println(b>i);
	}

}
